package com.by.config;

import feign.Feign;
import feign.Logger;
import feign.Request;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author ServivE
 * @version 0.1
 * @className FeignConfig
 * @description
 * @date 2024/10/30 14:04
 * @since jdk17
 */
@Configuration
public class FeignConfig {

    /**
     * feign日志级别
     * @return
     */
    @Bean
    public Logger.Level level() {
//        return Logger.Level.BASIC;
//        return Logger.Level.HEADERS;
        return Logger.Level.FULL;
    }

    /**
     * 授权 每次调用远程服务时  会增加请求头
     * @return
     */
    //@Bean
    public BasicAuthRequestInterceptor basicAuthRequestInterceptor(){
        return new BasicAuthRequestInterceptor("admin","123456");
    }

    @Bean
    public TokenInterceptor tokenInterceptor(){
        return new TokenInterceptor();
    }

    /**
     * 配置超时时间
     * 连接超时1ms  读取超时1ms
     * @return
     */
    //@Bean
    public Request.Options options() {
        return new Request.Options(1, TimeUnit.MILLISECONDS, 1, TimeUnit.MILLISECONDS, true);
    }


}
